//# sourceURL=http://uMapApp/Module/EventAlert/EventAlertBlock
define([
    "mhjs/mhjs"
    , "../../UI/Panel/PanelBlock/PanelBlock"
    , "../../UI/Slider"
], function (
    mhjs
    , PanelBlock
    , Slider
) {

    function EventAlert(option) {

        var _this = this;
        _this.isOpened = false;

        _this.ui = {
            slider: new Slider({"class": "slider"})
        };

        PanelBlock.call(_this, option);
        _this.addClass("eventAlertBlock propertiesBlock row");

    }

    var _class = EventAlert;
    mhjs.Inherit(_class, PanelBlock);


    Object.defineProperties(_class.prototype, {
        "properties"  : {
            set: function (properties) {
                var _this = this;
                _this._properties = properties;

                _this.ui.wrap.empty();

                _this.title = "预警信息";

                _this.ui.wrap
                    .append(_this.ui.slider)
                    .append(_this.renderBasic())
                ;


            },
            get: function () {
                return this._properties;
            }
        },
        "load"        : {
            value: function () {
                var _this = this;

                if (!_this.imgurl && _this._properties && _this._properties.picture && _this._properties.picture !== "") {

                    _this.imgurl = _this._properties.picture.split(";");
                    _this.ui.slider.list = _this.imgurl;
                }

            }
        },
        "renderBasic" : {
            value: function () {
                var _this = this;

                return _this.renderTree("预警信息", {
                    "预警时间" : new Date(_this.properties.time).format("yyyy-MM-dd hh:mm:ss"),
                    "预警信息" : _this.properties.alarmTypeO.alarmTypeName,
                    "预警类型" : _this.properties.alarmTypeGroup.groupName,
                    "预警级别" : _this.properties.alarmGrade,
                    "摄像头名称": _this.properties.deviceName
                    // "摄像头状态": _this.properties.camera.status,
                    // "预警级别":_this.properties.alarmGrade
                    // "预警位置" : _this.properties.stakeNum.str,
                });

            }
        },
        "renderTree"  : {
            value: function (label, value) {

                var _this = this;
                var result;

                if (typeof value !== "object" || value === undefined) {
                    result = _this.renderItem(label, value);
                } else {
                    result = _this.renderFolder(label);

                    $.each(value, function (childLabel, childValue) {
                        result.child.append(_this.renderTree(childLabel, childValue));
                    });
                }

                return result;

            }
        },
        "renderFolder": {
            value: function (label) {

                var folder = new mhjs.Div({"class": "folder"});
                folder.label = new mhjs.Div({"class": "label"});
                folder.label.text(label);
                folder.child = new mhjs.Div({"class": "child"});

                folder
                    .append(folder.label)
                    .append(folder.child)
                ;
                return folder;
            }
        },
        "renderItem"  : {
            value: function (label, value) {

                var item = new mhjs.Div({"class": "item"});
                item.label = new mhjs.Div({"class": "label"});
                item.label.text(label);
                item.valuetext = new mhjs.Div({"class": "value"});
                item.valuetext.text(value);

                item
                    .append(item.label)
                    .append(item.valuetext)
                ;
                return item;
            }
        },
        "map"         : {
            set: function (map) {
                var _this = this;
                _this._map = new mhjs.Map(map);
            },
            get: function () {
                return this._map;
            }
        }
    });

    return _class;

});